#include "color.h"

ColorInt Color_RGB(uint8_t red, uint8_t green, uint8_t blue) {
    return Color_ARGB(0xFF, red, green, blue);
}

ColorInt Color_ARGB(uint8_t alpha, uint8_t red, uint8_t green, uint8_t blue) {
    return ((ColorInt)alpha << 24) | ((ColorInt)red << 16) | ((ColorInt)green << 8) | (ColorInt)blue;
}

ColorInt Color_ARGB2(Color *color) {
    return Color_ARGB(color->alpha, color->red, color->green, color->blue);
}

Color Color_Parse(ColorInt colorInt) {
    Color color;

    color.alpha = colorInt >> 24;
    color.red = (colorInt >> 16) & 0xFF;
    color.green = (colorInt >> 8) & 0xFF;
    color.blue = colorInt & 0xFF;

    return color;
}

ColorInt Color_Random() {
    uint8_t alpha = 255;
    uint8_t red = rand() % 256;
    uint8_t green = rand() % 256;
    uint8_t blue = rand() % 256;

    return Color_ARGB(alpha, red, green, blue);
}
